package com.cubesugar2014.secretcard;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;

public class SetupActivity extends Activity {

	public static final String PREFS_NAME = "ScardPrefsFile";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		//requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_setup);
		
		
	    Switch autoActivate = (Switch)findViewById(R.id.switch1);
	    Switch startup = (Switch)findViewById(R.id.switch2);
		
	    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
		boolean auto = settings.getBoolean("autoActivation", true);
		boolean start = settings.getBoolean("startup", true);

		autoActivate.setChecked(auto);
		startup.setChecked(start);
		
		
	    autoActivate.setOnCheckedChangeListener(new OnCheckedChangeListener() 
		{      
			@Override   
			public void onCheckedChanged(CompoundButton buttonView,      boolean isChecked) 
			{      
				SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
				SharedPreferences.Editor editor = settings.edit();
	        	
				
				if(isChecked)
				{      
					//switchStatus.setText("Switch is currently ON"); 
					editor.putBoolean("autoActivation", true);
					
				}else{     
					//switchStatus.setText("Switch is currently OFF");   
					editor.putBoolean("autoActivation", false);
				}     
				// Commit the edits!
	        	editor.commit();
			}   
		});   
	    
	    startup.setOnCheckedChangeListener(new OnCheckedChangeListener() 
		{      
			@Override   
			public void onCheckedChanged(CompoundButton buttonView,      boolean isChecked) 
			{      
				SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
				SharedPreferences.Editor editor = settings.edit();
	        	   
				if(isChecked)
				{      
					//switchStatus.setText("Switch is currently ON"); 
					editor.putBoolean("startup", true);
					
					
				}else{     
					//switchStatus.setText("Switch is currently OFF");   
					editor.putBoolean("startup", false);
						
				}     
							
	        	// Commit the edits!
	        	editor.commit();
	        	    
			}   
		});   
	    
	    
	}
}